﻿using OpenTK.Graphics;
using OpenTK.Math;
using System.Drawing;
using Rekx.Graphics;

namespace Rekx.Pong
{

    /// <summary>
    /// 
    /// </summary>
    public static class Rectangle
    {
        /// <summary>
        /// Construct a rectangle with a given position, width, and height.
        /// </summary>
        /// <param name="width">The rectangle's width</param>
        /// <param name="height">The rectangle's height</param>
        public static DrawableComponent CreateRectangularComponent(float width, float height)
        {
            float halfWidth = width * 0.5f;
            float halfHeight = height * 0.5f;

            // Setup vertex and index arrays
            Vector3[] vertices = new Vector3[]
            {
                new Vector3(- halfWidth, 0.0f, - halfHeight),
                new Vector3(+ halfWidth, 0.0f, - halfHeight),
                new Vector3(- halfWidth, 0.0f, + halfHeight),
                new Vector3(+ halfWidth, 0.0f, + halfHeight)
            };

            int[] indices = new int[]
            {
                0,
                1,
                2,
                3
            };

            return new DrawableComponent(vertices, indices);
        }
    }
}